package com.bawei.room_test;

import java.util.List;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;

@Dao
public interface StudentDao {
    //插入一条数据
    @Insert(onConflict = OnConflictStrategy.REPLACE)//重复替换
    void insert(Student student);
    //插入多条数据
    @Insert(onConflict = OnConflictStrategy.REPLACE)//重复替换
    void insertList(List<Student> list);
    //删除一条数据
    @Delete
    void delete(Student student);
    //删除多条
    @Delete
    void deleteList(List<Student> list);
    //删除全部:注意是query
    @Query("delete from student2")
    void deleteAll();
    //修改
    @Update
    void update(Student student);
    //查询
    @Query("select * from student2")
    List<Student> selectAll();
    //条件查询
    @Query("select * from student2 where username = :username")
    List<Student> selectByName(String username);


}
